﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SmartTracking.Infrastructure.Interfaces
{
    public interface IBaseRepository<T>
    {
        DataDbContext DB { get; }

        /// <summary>
        /// 新增异步
        /// </summary>
        /// <param name="entity">实体</param>
        /// <returns>返回任务</returns>
        Task<int> AddAsync(T entity);
        /// <summary>
        /// 新增批量
        /// </summary>
        /// <param name="list">数据</param>
        /// <returns>返回任务</returns>
        Task<int> AddRangeAsync(List<T> list);
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="entity">实体</param>
        /// <returns>返回任务</returns>
        Task<int> UpdateAsync(T entity);
        /// <summary>
        /// 批量修改
        /// </summary>
        /// <param name="list">数据</param>
        /// <returns>返回任务</returns>
        Task<int> UpdateRangeAsync(List<T> list);
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="entity">实体</param>
        /// <returns>返回任务</returns>
        Task<int> DeleteAsync(T entity);
        /// <summary>
        /// 批量删除
        /// </summary>
        Task<int> DeleteRangeAsync(List<T> list);
        /// <summary>
        /// 查询所有
        /// </summary>
        /// <returns>返回任务</returns>
        IQueryable<T> GetAll();
        /// <summary>
        /// 根据Id异步获取单条数据
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        Task<T> GetByIdAsync(int Id);
    }
}
